package com.heima.comment.controller.v1;

import com.heima.comment.service.CommentRepayService;
import com.heima.model.common.dtos.CommentRepayDTO;
import com.heima.model.common.dtos.CommentRepayLikeDTO;
import com.heima.model.common.dtos.CommentRepaySaveDTO;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("//api/v1/comment_repay")
@Api(value = "评论回复管理API", tags = "评论回复管理API")
public class CommentRepayController {
    @Autowired
    private CommentRepayService CommentRepayService;

    //加载评论回复列表
    @PostMapping("/load")
    @ApiOperation("加载评论回复列表")
    public ResponseResult loadCommentRepay(@RequestBody @Validated CommentRepayDTO dto) {
        return CommentRepayService.loadCommentRepay(dto);
    }

    //保存评论回复
    @PostMapping("/save")
    @ApiOperation("保存评论回复")
    public ResponseResult saveCommentRepay(@RequestBody @Validated CommentRepaySaveDTO dto) {
        return CommentRepayService.saveCommentRepay(dto);
    }

    //保存评论回复的点赞信息
    @PostMapping("/like")
    @ApiOperation("保存评论回复的点赞信息")
    public ResponseResult saveCommentRepayLike(@RequestBody @Validated CommentRepayLikeDTO dto) {
        return CommentRepayService.saveCommentRepayLike(dto);
    }
}
